@extends('layouts.admin.application')

@section('content')
    <div class="main-content">
        <div class="col-xs-12">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i><a href="{{route('cashier.sale.index')}}">首页</a></li>
                    <li>会员消费记录</li>
                </ul>
            </div>

            @include('layouts.partials._flash')

            <div class="table-responsive">
                <div id="sample-table-2_wrapper" class="dataTables_wrapper" role="grid">
                    <div class="row">
                        <form action="{{route('cashier.sale.member_sale')}}" method="get">
                            <div class="col-sm-10">
                                <div class="dataTables_filter" id="sample-table-2_filter">

                                    <label><input type="text" name="name" value="{{Request::input('name')}}"
                                                  aria-controls="sample-table-2"
                                                  placeholder="按会员名字">
                                    </label>
                                    <label>
                                        <select name="store_id" class="dataTables_filter" style="width: 130px;">
                                            <option value="-1">按店铺</option>

                                            @foreach($stores as $store)
                                                <option value="{{$store->id}}"
                                                        @if($store->id == Request::input('store_id')) selected @endif>{{$store->name}}</option>
                                            @endforeach

                                        </select>
                                    </label>
                                    <label>
                                        <button type="submit" class="btn btn-xs btn-info" id="search">确定</button>
                                        <a href="{{route('cashier.sale.member_sale')}}" class="btn btn-xs btn-default">重置</a>
                                    </label>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="row">
                        <div class="alert alert-block alert-success">
                            各门店所有会员消费记录
                            <strong class="green">
                                按 会员 分组
                            </strong>
                        </div>
                        <div class="table-responsive">
                            <div id="sample-table-2_wrapper" class="dataTables_wrapper" role="grid">
                                <div class="row">

                                    @include('layouts.partials._flash')

                                    <div class="timeline-container">
                                        <div class="timeline-items">
                                            <div class="timeline-item clearfix">
                                                <div class="timeline-info">
                                                    <i class="timeline-indicator icon-bug btn btn-pink no-hover"></i>
                                                </div>
                                                @foreach($member_records as $record)

                                                    <div class="widget-box">
                                                        <div class="widget-header header-color-green widget-header-small">
                                                            <span> 消费单号：{{$record->id}}</span> &nbsp;&nbsp;|&nbsp;&nbsp;
                                                            <span> 会员名称：{{$record->member['name']}} </span> &nbsp;&nbsp;|&nbsp;&nbsp;
                                                            <span><a href="tel:{{$record->member['phone']}}">{{$record->member['phone']}}</a></span>
                                                            &nbsp;&nbsp;|&nbsp;&nbsp;
                                                            <span> 消费时间：{{$record->pay_time}}</span>&nbsp;&nbsp;|&nbsp;&nbsp;
                                                            <span> 销售店铺：{{$record->store['name']}}</span>&nbsp;&nbsp;|&nbsp;&nbsp;
                                                            <span> 支付方式：{{order_pay_type($record->pay_type)}}</span>
                                                            <span class="widget-toolbar no-border">
                                                            <i class="icon-time bigger-110"></i> {{$record->created_at}}
                                                        </span>

                                                            <span class="widget-toolbar">
                                                            <a href="#" data-action="collapse">
                                                                <i class="icon-chevron-up"></i>
                                                            </a>
                                                        </span>
                                                        </div>

                                                        <div class="widget-body">
                                                            <div class="widget-body-inner" style="display: block;">
                                                                <div class="widget-main">
                                                                    <table id="sample-table-2"
                                                                           class="table table-striped table-bordered table-hover dataTable del-table"
                                                                           aria-describedby="sample-table-2_info">
                                                                        <thead>
                                                                        <tr role="row">
                                                                            <th>编号</th>
                                                                            <th>商品名称</th>
                                                                            <th>规格</th>
                                                                            <th>单位</th>
                                                                            <th>零售价</th>
                                                                            <th>积分</th>
                                                                            <th>购买时间</th>
                                                                            <th>销售店铺</th>
                                                                        </tr>
                                                                        </thead>
                                                                        <tbody>
                                                                        @foreach($record->sale_products as $product)
                                                                            <tr class="odd" data-id="">
                                                                                <td>{{$product->product['id']}}</td>
                                                                                <td>{{$product->product['name']}}</td>
                                                                                <td>{{$product->product['spec']}}</td>
                                                                                <td>{{$product->product['unit']}}</td>
                                                                                <td>{{$product->product['price']}}</td>
                                                                                <td>{{$record->member['score']}}</td>
                                                                                <td>{{$record->pay_time}}</td>
                                                                                <td>{{$record->store['name']}}</td>
                                                                            </tr>
                                                                        @endforeach
                                                                        </tbody>
                                                                    </table>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                @endforeach

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-6">共 {{$member_records->total()}} 条记录</div>
                        <div class="col-sm-6">
                            <div class="dataTables_paginate paging_bootstrap">
                                <ul class="pagination">
                                    {{ $member_records->appends(Request::all())->links() }}
                                </ul>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
@endsection


